package com.djzhou.gmms.service.dictionary.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;

import com.djzhou.gmms.model.dictionary.TbDictionary;
import com.djzhou.gmms.model.entity.PageBean;
import com.djzhou.gmms.model.user.VoResource;
import com.djzhou.gmms.service.base.impl.BaseServiceImpl;
import com.djzhou.gmms.service.dictionary.DictionaryService;

public class DictionaryServiceImpl  extends BaseServiceImpl implements DictionaryService{

	@Override
	public void add(TbDictionary t) {
		dictionaryDAO.insert(t);
		
	}

	@Override
	public void delete(Integer id) {
		TbDictionary dictionary=dictionaryDAO.queryByID(TbDictionary.class, id);
		dictionary.setDeleteFlag(1);
		dictionaryDAO.update(dictionary);
		
	}

	@Override
	public TbDictionary queryById(Integer id) {
		return dictionaryDAO.queryByID(TbDictionary.class, id);
	}

	@Override
	public List<TbDictionary> queryList(HashMap<String, Object> hashMap) {
		
		return null;
	}

	@Override
	public PageBean<TbDictionary> queryPageBean(HashMap<String, Object> hashMap, int pageSize, int currentPage) {
		String hql="from TbDictionary dictionary where dictionary.deleteFlag=0";
		String dictionaryTypeId=null;
		StringBuffer sb=new StringBuffer();
		sb.append(hql);
		if(hashMap!=null && hashMap.size()!=0){
			if(hashMap.get("dictionaryTypeId")!=null){
				dictionaryTypeId=hashMap.get("dictionaryTypeId").toString();
				sb.append(" and dictionary.dictionaryType.dictionaryTypeId=").append(dictionaryTypeId);
			}
		}
		sb.append(" order by createTime desc");
		hql=sb.toString();
		return dictionaryDAO.selectByPage(hql, pageSize, currentPage);
	}

	@Override
	public void update(TbDictionary t) {
		dictionaryDAO.update(t);
		
	}
	@Override
	public VoResource query4AutoComplete(HashMap<String, Object> hashMap, String sidx,
			String sord, int pageSize, int currentPage) {
		// TODO Auto-generated method stub
		return null;
	}

}
